<?php
/**
 * Created by PhpStorm.
 * User: yuanjie
 * Date: 16/5/31
 * Time: 下午2:38
 */

$api_service_path = __DIR__ . "/../../../api/";
ob_start();
require_once($api_service_path . "public/index.php");
ob_end_clean();

$services = DB::table('service_classification')->select(array('id','name','parent_id','level'))->where('status',1)->get();
foreach ($services as $_service){
    $pinyin = Pinyin::getShortPinyin($_service->name);
    DB::table('service')->insert(
        array(
            'id' => $_service->id,
            'name' => $_service->name,
            'retrieval_code' => $pinyin,
            'classify' => $_service->id,
            'status' => 1,
            'parent_id' => $_service->parent_id,
            'level' => $_service->level,
        )
    );
}